package com.learn.base.exception;

import com.learn.base.enums.ResultCode;
import org.springframework.http.HttpStatus;

/**
 * @author : Yu.Tan
 * @date : 2023/1/17 18:06
 * @desc : **
 */
public class BusinessException extends RuntimeException{


    /**
     *
     */
    private static final long serialVersionUID = -4137688758944857209L;

    /**
     * http状态码
     */
    private Integer httpStatusCode;

    private Object object;

    /**
     * @param httpStatus http状态码
     */
    public BusinessException(ResultCode httpStatus) {
        super(httpStatus.getMessage());
        this.httpStatusCode = httpStatus.getCode();
    }

    /**
     * @param httpStatus http状态码
     */
    public BusinessException(ResultCode httpStatus, String msg) {
        super(msg);
        this.httpStatusCode = httpStatus.getCode();
    }


    public BusinessException(String msg) {
        super(msg);
        this.httpStatusCode = HttpStatus.BAD_REQUEST.value();
    }

    public BusinessException(String msg, Object object) {
        super(msg);
        this.httpStatusCode = HttpStatus.BAD_REQUEST.value();
        this.object = object;
    }

    public Integer getHttpStatusCode() {
        return httpStatusCode;
    }

}
